library(tidyverse)
library(haven)
library(stargazer)
library(broom)
library(scales)
library(ggpubr)
library(dplyr)
library(kableExtra)

df <- read.csv("climate_qualtrics.csv")

#### Table 3: N per Condition #### 
df <- df %>% mutate(repub = case_when(Q3.1 == "Republican" | Q3.4 == "Republican Party" ~ "Republican",
                                      Q3.1 =="Democrat" | Q3.4 == "Democratic Party"| Q3.4 == "Neither Party" ~ "Non-Republican"))

df %>% group_by(repub, FL_8_DO) %>%
  tally() %>%
  spread(repub ,n) %>% kbl(format="latex")%>% kable_styling(latex_option = "hold_position")

df %>% filter(treatment==1) %>% 
  filter(Q3.1 == "Republican" & Q3.2 == "Strong") %>%
  group_by(FL_8_DO) %>% tally()

df %>% filter(treatment==0) %>% 
  filter(Q3.1 == "Republican" & Q3.2 == "Strong") %>%
  group_by(FL_8_DO) %>% tally()

df %>% filter(treatment==1) %>% 
  filter(Q3.1 == "Republican" & Q3.2 == "Not Very Strong" | Q3.4 == "Republican Party") %>%
  group_by(FL_8_DO) %>% tally()

nrow(df %>% filter(Q3.1 == "Republican" & Q3.2 == "Not Very Strong" | Q3.4 == "Republican Party"))
nrow(df %>% filter(Q3.1 == "Republican" & Q3.2 == "Strong"))
nrow(df %>% filter(Q3.1 == "Republican" | Q3.4 == "Republican Party"))
nrow(df %>% filter(Q3.1 == "Democrat" | Q3.4 == "Democratic Party"| Q3.4 == "Neither Party"))


#### Figure 3: Local Media Effect on Climate Attitudes (Climate Disaster Conditions) ####
# All Republicans ####
mod1 <- lm(credible ~ as.factor(FL_8_DO), data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Republican" | Q3.4 == "Republican Party"))
mod2 <- lm(relevant ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Republican" | Q3.4 == "Republican Party"))
mod3 <- lm(happening~ as.factor(FL_8_DO) , data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Republican" | Q3.4 == "Republican Party"))

mod4 <- lm(serious ~ as.factor(FL_8_DO), data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Republican" | Q3.4 == "Republican Party"))
mod5 <- lm(harm.when ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Republican"| Q3.4 == "Republican Party"))
mod6 <- lm(action ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Republican" | Q3.4 == "Republican Party"))


summary(mod1)
summary(mod2)

model1 <- mod1 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Credible") 
model1 <- mod2 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Relevant") %>%
  bind_rows(model1)
model1 <- mod3 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Happening") %>%
  bind_rows(model1)
model1 <- mod4 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Serious") %>%
  bind_rows(model1)
model1 <- mod5 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Harm") %>%
  bind_rows(model1)
model1 <- mod6 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Action") %>%
  bind_rows(model1)
model1 <- model1 %>% 
  mutate(group="All Republicans")

model1 <- model1 %>% 
  mutate(DV = fct_relevel(factor(DV), "Credible","Relevant", "Happening", "Serious", "Harm", "Action"),
         term = case_when(term =="as.factor(FL_8_DO)NationalNews,NYT" ~ "Local - NYT",
                          term == "as.factor(FL_8_DO)NationalNews,Treatment" ~ "Local - USA Today"))
labels = c("Credible","Relevant", "Happening", "Serious", "Harm", "Action")


#### Strong Republicans ####
mod1 <- lm(credible ~ as.factor(FL_8_DO), data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Strong"))
mod2 <- lm(relevant ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Strong"))
mod3 <- lm(happening ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Strong"))

mod4 <- lm(serious ~ as.factor(FL_8_DO), data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Strong"))
mod5 <- lm(harm.when ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==1) %>%
          filter(Q3.1 == "Republican" & Q3.2 == "Strong"))
mod6 <- lm(action ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Strong"))
#summary(mod5)
#0.06498/sd(df$harm.when, na.rm=T)

model2 <- mod1 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Credible") 
model2 <- mod2 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Relevant") %>%
  bind_rows(model2)
model2 <- mod3 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Happening") %>%
  bind_rows(model2)
model2 <- mod4 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Serious") %>%
  bind_rows(model2)
model2 <- mod5 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Harm") %>%
  bind_rows(model2)
model2 <- mod6 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Action") %>%
  bind_rows(model2)
model2 <- model2 %>% 
  mutate(group="Strong Republicans")

model2 <- model2 %>% 
  mutate(DV = fct_relevel(factor(DV), "Credible","Relevant", "Happening", "Serious", "Harm", "Action"),
         term = case_when(term =="as.factor(FL_8_DO)NationalNews,NYT" ~ "Local - NYT",
                          term == "as.factor(FL_8_DO)NationalNews,Treatment" ~ "Local - USA Today"))
labels = c("Credible","Relevant", "Happening", "Serious", "Harm", "Action")


#### Weak Republicans ####
mod1 <- lm(credible ~ as.factor(FL_8_DO), data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Not Very Strong" | Q3.4 == "Republican Party"))
mod2 <- lm(relevant ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Not Very Strong" | Q3.4 == "Republican Party"))
mod3 <- lm(happening ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Not Very Strong" | Q3.4 == "Republican Party"))

mod4 <- lm(serious ~ as.factor(FL_8_DO), data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Not Very Strong" | Q3.4 == "Republican Party"))
mod5 <- lm(harm.when ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Not Very Strong" | Q3.4 == "Republican Party"))
mod6 <- lm(action ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Not Very Strong" | Q3.4 == "Republican Party"))
# summary(mod4)
#0.06498/sd(df$harm.when, na.rm=T)

model3 <- mod1 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Credible") 
model3 <- mod2 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Relevant") %>%
  bind_rows(model3)
model3 <- mod3 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Happening") %>%
  bind_rows(model3)
model3 <- mod4 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Serious") %>%
  bind_rows(model3)
model3 <- mod5 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Harm") %>%
  bind_rows(model3)
model3 <- mod6 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Action") %>%
  bind_rows(model3)
model3 <- model3 %>% 
  mutate(group="Weak Republicans")

model3 <- model3 %>% 
  mutate(DV = fct_relevel(factor(DV), "Credible","Relevant", "Happening", "Serious", "Harm", "Action"),
         term = case_when(term =="as.factor(FL_8_DO)NationalNews,NYT" ~ "Local - NYT",
                          term == "as.factor(FL_8_DO)NationalNews,Treatment" ~ "Local - USA Today"))
labels = c("Credible","Relevant", "Happening", "Serious", "Harm", "Action")



#### Non-Republicans####
mod1 <- lm(credible ~ as.factor(FL_8_DO), data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Democrat" | Q3.4 == "Democratic Party" | Q3.4 == "Neither Party"))
mod2 <- lm(relevant ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Democrat" | Q3.4 == "Democratic Party" | Q3.4 == "Neither Party"))
mod3 <- lm(happening~ as.factor(FL_8_DO) , data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Democrat" | Q3.4 == "Democratic Party" | Q3.4 == "Neither Party"))
mod4 <- lm(serious ~ as.factor(FL_8_DO), data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Democrat" | Q3.4 == "Democratic Party" | Q3.4 == "Neither Party"))
mod5 <- lm(harm.when ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Democrat" | Q3.4 == "Democratic Party" | Q3.4 == "Neither Party"))
mod6 <- lm(action ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==1) %>%
             filter(Q3.1 == "Democrat" | Q3.4 == "Democratic Party" | Q3.4 == "Neither Party"))

model4 <- mod1 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Credible") 
model4 <- mod2 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Relevant") %>%
  bind_rows(model4)
model4 <- mod3 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Happening") %>%
  bind_rows(model4)
model4 <- mod4 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Serious") %>%
  bind_rows(model4)
model4 <- mod5 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Harm") %>%
  bind_rows(model4)
model4 <- mod6 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Action") %>%
  bind_rows(model4)
model4 <- model4 %>% 
  mutate(group="Non-Republicans")

model4 <- model4 %>% 
  mutate(DV = fct_relevel(factor(DV), "Credible","Relevant", "Happening", "Serious", "Harm", "Action"),
         term = case_when(term =="as.factor(FL_8_DO)NationalNews,NYT" ~ "Local - NYT",
                          term == "as.factor(FL_8_DO)NationalNews,Treatment" ~ "Local - USA Today"))
labels = c("Credible","Relevant", "Happening", "Serious", "Harm", "Action")

model4

models <- model1 %>% bind_rows(model2) %>% 
  bind_rows(model3) %>% bind_rows(model4)

models$group_f = factor(models$group, levels = c("All Republicans", "Strong Republicans", "Weak Republicans",  "Non-Republicans"))


ggplot(models, aes(group=term, shape = term)) + facet_wrap(vars(group_f), nrow = 1) +
  #  facet_grid(partyID~var) +
  # facet_grid(vars(DV) ,labeller = labeller(DV= label_wrap_gen(20)), nrow=2) + 
  geom_pointrange(aes(-estimate, rev(DV), xmin = ll, xmax = ul, color=term), alpha=0.3, position = position_dodge(width = 0.3)) + 
  geom_pointrange(aes(-estimate, rev(DV), xmin=lll, xmax=ull, color=term), position = position_dodge(width=0.3)) + 
  geom_vline(xintercept = 0, lty = 2, col = "grey") +  coord_cartesian(xlim=c(-0.1, 0.2)) + 
  #  scale_x_continuous(breaks=c(-0.1, -0.05,  0, 0.05, 0.1, 0.15)) + 
  scale_color_manual(values = c("grey50", "grey20")) +
  scale_y_discrete(name="", labels=rev(labels)) + theme_bw()+ theme(legend.title = element_blank(),
                                                                    panel.grid.major = element_blank())+
  labs(x = "",
       y = "")





#### Figure 4: Local Media Effect on Republicans' Climate Attitudes Coefficient Plots (Neutral)####
# All Republicans ####
mod1 <- lm(credible ~ as.factor(FL_8_DO), data = df %>% filter(treatment==0) %>%
             filter(Q3.1 == "Republican" | Q3.4 == "Republican Party"))
mod2 <- lm(relevant ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==0) %>%
             filter(Q3.1 == "Republican" | Q3.4 == "Republican Party"))
mod3 <- lm(happening~ as.factor(FL_8_DO) , data = df %>% filter(treatment==0) %>%
             filter(Q3.1 == "Republican" | Q3.4 == "Republican Party"))

mod4 <- lm(serious ~ as.factor(FL_8_DO), data = df %>% filter(treatment==0) %>%
             filter(Q3.1 == "Republican" | Q3.4 == "Republican Party"))
mod5 <- lm(harm.when ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==0) %>%
             filter(Q3.1 == "Republican"| Q3.4 == "Republican Party"))
mod6 <- lm(action ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==0) %>%
             filter(Q3.1 == "Republican" | Q3.4 == "Republican Party"))

model1 <- mod1 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Credible") 
model1 <- mod2 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Relevant") %>%
  bind_rows(model1)
model1 <- mod3 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Happening") %>%
  bind_rows(model1)
model1 <- mod4 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Serious") %>%
  bind_rows(model1)
model1 <- mod5 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Harm") %>%
  bind_rows(model1)
model1 <- mod6 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Action") %>%
  bind_rows(model1)
model1 <- model1 %>% 
  mutate(group="All Republicans")

model1 <- model1 %>% 
  mutate(DV = fct_relevel(factor(DV), "Credible","Relevant", "Happening", "Serious", "Harm", "Action"),
         term = case_when(term == "as.factor(FL_8_DO)NationalNews,Control" ~ "Local - USA Today"))
labels = c("Credible","Relevant", "Happening", "Serious", "Harm", "Action")



#### Strong Republicans ####
mod1 <- lm(credible ~ as.factor(FL_8_DO), data = df %>% filter(treatment==0) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Strong"))
mod2 <- lm(relevant ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==0) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Strong"))
mod3 <- lm(happening ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==0) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Strong"))

mod4 <- lm(serious ~ as.factor(FL_8_DO), data = df %>% filter(treatment==0) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Strong"))
mod5 <- lm(harm.when ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==0) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Strong"))
mod6 <- lm(action ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==0) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Strong"))
# summary(mod4)
#0.06498/sd(df$harm.when, na.rm=T)

model2 <- mod1 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Credible") 
model2 <- mod2 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Relevant") %>%
  bind_rows(model2)
model2 <- mod3 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Happening") %>%
  bind_rows(model2)
model2 <- mod4 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Serious") %>%
  bind_rows(model2)
model2 <- mod5 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Harm") %>%
  bind_rows(model2)
model2 <- mod6 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Action") %>%
  bind_rows(model2)
model2 <- model2 %>% 
  mutate(group="Strong Republicans")

model2 <- model2 %>% 
  mutate(DV = fct_relevel(factor(DV), "Credible","Relevant", "Happening", "Serious", "Harm", "Action"),
         term = case_when(term == "as.factor(FL_8_DO)NationalNews,Control"~ "Local - USA Today"))
labels = c("Credible","Relevant", "Happening", "Serious", "Harm", "Action")

#### Weak Republicans ####
mod1 <- lm(credible ~ as.factor(FL_8_DO), data = df %>% filter(treatment==0) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Not Very Strong" | Q3.4 == "Republican Party"))
mod2 <- lm(relevant ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==0) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Not Very Strong" | Q3.4 == "Republican Party"))
mod3 <- lm(happening ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==0) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Not Very Strong" | Q3.4 == "Republican Party"))

mod4 <- lm(serious ~ as.factor(FL_8_DO), data = df %>% filter(treatment==0) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Not Very Strong" | Q3.4 == "Republican Party"))
mod5 <- lm(harm.when ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==0) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Not Very Strong" | Q3.4 == "Republican Party"))
mod6 <- lm(action ~ as.factor(FL_8_DO) , data = df %>% filter(treatment==0) %>%
             filter(Q3.1 == "Republican" & Q3.2 == "Not Very Strong" | Q3.4 == "Republican Party"))
# summary(mod4)
#0.06498/sd(df$harm.when, na.rm=T)

model3 <- mod1 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Credible") 
model3 <- mod2 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Relevant") %>%
  bind_rows(model3)
model3 <- mod3 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Happening") %>%
  bind_rows(model3)
model3 <- mod4 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Serious") %>%
  bind_rows(model3)
model3 <- mod5 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Harm") %>%
  bind_rows(model3)
model3 <- mod6 %>% tidy() %>%
  slice(-1) %>%
  mutate(ul = -estimate + 1.96 * std.error,
         ll = -estimate - 1.96 * std.error,
         ull = -estimate + 1.64 * std.error,
         lll = -estimate - 1.64 * std.error,
         DV = "Action") %>%
  bind_rows(model3)
model3 <- model3 %>% 
  mutate(group="Weak Republicans")

model3 <- model3 %>% 
  mutate(DV = fct_relevel(factor(DV), "Credible","Relevant", "Happening", "Serious", "Harm", "Action"),
         term = case_when(term == "as.factor(FL_8_DO)NationalNews,Control" ~ "Local - USA Today"))
labels = c("Credible","Relevant", "Happening", "Serious", "Harm", "Action")

models <- model1 %>% bind_rows(model2) %>% 
  bind_rows(model3)
models
ggplot(models, aes(group=term, shape = term)) + facet_wrap(vars(group), nrow = 1) +
  #  facet_grid(partyID~var) +
  # facet_grid(vars(DV) ,labeller = labeller(DV= label_wrap_gen(20)), nrow=2) + 
  geom_pointrange(aes(-estimate, rev(DV), xmin = ll, xmax = ul, color=term), alpha=0.3, position = position_dodge(width = 0.3)) + 
  geom_pointrange(aes(-estimate, rev(DV), xmin=lll, xmax=ull, color=term), position = position_dodge(width=0.3)) + 
  geom_vline(xintercept = 0, color = "gray", lty=2)  + 
  #  scale_x_continuous(breaks=c(-0.1, -0.05,  0, 0.05, 0.1, 0.15)) + 
  scale_color_manual(values = c("grey30")) +
  scale_y_discrete(name="", labels=rev(labels)) + theme_bw()+ theme(legend.title = element_blank(),
                                                                    panel.grid.major = element_blank())+
  labs(x = "",
       y = "")



